WPS Office.apk(点击下载) / abjn.java


package defpackage;

import cn.wps.shareplay.message.Message;
import com.fasterxml.jackson.core.util.MinimalPrettyPrinter;
import com.mopub.nativeads.MoPubNativeAdPositioning;
import defpackage.abjm;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.dom4j.DocumentFactory;
import org.xml.sax.Attributes;
import org.xml.sax.DTDHandler;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.ext.DeclHandler;
import org.xml.sax.ext.LexicalHandler;
import org.xml.sax.helpers.DefaultHandler;

/* renamed from: abjn  reason: default package */
public final class abjn extends DefaultHandler implements DTDHandler, DeclHandler, LexicalHandler {
    private abjl CSA;
    private abkw CSB;
    private abis CSC;
    private abir CSD;
    abjm CSE;
    private DocumentFactory CSi;
    private abio CSz;
    private StringBuffer aTA;
    boolean aTB;
    private int aTD;
    private Locator aTg;
    private String aTh;
    private boolean aTi;
    private boolean aTj;
    private StringBuffer aTk;
    private Map aTl;
    private List aTm;
    private List aTn;
    private List aTo;
    private int aTp;
    EntityResolver aTq;
    InputSource aTr;
    boolean aTt;
    boolean aTu;
    private int aTv;
    private boolean aTw;
    boolean aTx;
    private boolean aTy;
    boolean aTz;

    public abjn() {
        this(DocumentFactory.hfO());
    }

    public abjn(DocumentFactory documentFactory) {
        this(documentFactory, (abis) null, false);
    }

    public abjn(DocumentFactory documentFactory, abis abis, abjl abjl) {
        this.aTl = new HashMap();
        this.aTm = new ArrayList();
        this.aTt = false;
        this.aTu = false;
        this.aTw = false;
        this.aTx = false;
        this.aTy = false;
        this.aTz = false;
        this.aTB = false;
        this.aTD = -1;
        this.CSi = documentFactory;
        this.CSC = abis;
        this.CSA = abjl;
        this.CSB = new abkw(documentFactory);
    }

    public abjn(DocumentFactory documentFactory, abis abis, boolean z) {
        this(documentFactory, abis, (abjl) null);
        this.CSA = new abjl(z);
    }

    private void Ix() throws abjk {
        if (this.aTB) {
            String trim = this.aTA.toString().trim();
            if (trim.length() > 0) {
                this.CSD.ajm(trim);
                if (this.CSC != null) {
                    this.CSC.cz(trim);
                }
            }
        } else {
            String stringBuffer = this.aTA.toString();
            this.CSD.ajm(stringBuffer);
            if (this.CSC != null) {
                this.CSC.cz(stringBuffer);
            }
        }
        this.aTA.setLength(0);
        this.aTy = false;
    }

    private void cT(Object obj) {
        if (this.aTn == null) {
            this.aTn = new ArrayList();
        }
        this.aTn.add(obj);
    }

    private void cU(Object obj) {
        if (this.aTo == null) {
            this.aTo = new ArrayList();
        }
        this.aTo.add(obj);
    }

    private String getEncoding() {
        if (this.aTg == null) {
            return null;
        }
        try {
            Method method = this.aTg.getClass().getMethod("getEncoding", new Class[0]);
            if (method != null) {
                return (String) method.invoke(this.aTg, new Object[0]);
            }
        } catch (Exception e) {
        }
        return null;
    }

    @Override // org.xml.sax.ext.DeclHandler
    public final void attributeDecl(String str, String str2, String str3, String str4, String str5) throws SAXException {
        if (this.aTw) {
            if (this.aTt) {
                cT(new abjd(str, str2, str3, str4, str5));
            }
        } else if (this.aTu) {
            cU(new abjd(str, str2, str3, str4, str5));
        }
    }

    @Override // org.xml.sax.helpers.DefaultHandler, org.xml.sax.ContentHandler
    public final void characters(char[] cArr, int i, int i2) throws SAXException {
        if (i2 != 0 && this.CSD != null) {
            if (!this.CSE.aSF && true == this.CSE.gq(this.aTD + 1)) {
                return;
            }
            if (this.aTh != null) {
                if (this.aTx && this.aTy) {
                    Ix();
                }
                this.CSD.iU(this.aTh, new String(cArr, i, i2));
                this.aTh = null;
            } else if (this.aTj) {
                if (this.aTx && this.aTy) {
                    Ix();
                }
                this.aTk.append(new String(cArr, i, i2));
            } else if (this.aTx) {
                this.aTA.append(cArr, i, i2);
                this.aTy = true;
            } else {
                this.CSD.ajm(new String(cArr, i, i2));
            }
        }
    }

    @Override // org.xml.sax.ext.LexicalHandler
    public final void comment(char[] cArr, int i, int i2) throws SAXException {
        if (!this.aTz) {
            if (this.aTx && this.aTy) {
                Ix();
            }
            String str = new String(cArr, i, i2);
            if (!this.aTi && str.length() > 0) {
                if (this.CSD != null) {
                    this.CSD.ajk(str);
                } else {
                    hfV().ajf(str);
                }
            }
        }
    }

    @Override // org.xml.sax.ext.DeclHandler
    public final void elementDecl(String str, String str2) throws SAXException {
        if (this.aTw) {
            if (this.aTt) {
                cT(new abje(str, str2));
            }
        } else if (this.aTu) {
            cU(new abje(str, str2));
        }
    }

    @Override // org.xml.sax.ext.LexicalHandler
    public final void endCDATA() throws SAXException {
        this.aTj = false;
        this.CSD.ajl(this.aTk.toString());
    }

    @Override // org.xml.sax.ext.LexicalHandler
    public final void endDTD() throws SAXException {
        this.aTi = false;
        abiq hfM = hfV().hfM();
        if (hfM != null) {
            if (this.aTn != null) {
                hfM.gl(this.aTn);
            }
            if (this.aTo != null) {
                hfM.gm(this.aTo);
            }
        }
        this.aTn = null;
        this.aTo = null;
    }

    @Override // org.xml.sax.helpers.DefaultHandler, org.xml.sax.ContentHandler
    public final void endDocument() throws SAXException {
        this.CSB.clear();
        this.CSA.clear();
        this.CSD = null;
        this.aTA = null;
    }

    @Override // org.xml.sax.helpers.DefaultHandler, org.xml.sax.ContentHandler
    public final void endElement(String str, String str2, String str3) throws SAXException {
        if (!this.CSE.aSF) {
            abjm abjm = this.CSE;
            int i = this.aTD;
            boolean gq = abjm.gq(i);
            if (true == gq) {
                abjm.c peek = abjm.CSq.aSK.size() <= 0 ? null : abjm.CSq.aSK.peek();
                ev.assertNotNull("top should not be null", peek);
                if (peek.aSI == i) {
                    abjm.CSq.aSK.pop();
                } else if (peek.aSJ == i) {
                    peek.aSJ--;
                }
            }
            abjm.CSo.azW(i);
            abjm.CSp.azW(i);
            abjm.CSn.azW(i);
            if (true == gq) {
                this.aTD--;
                return;
            }
        }
        if (this.aTx && this.aTy) {
            Ix();
        }
        ev.assertNotNull("currentElement should not be null", this.CSD);
        if (this.CSC != null) {
            this.CSC.b(this.CSA);
        }
        this.CSA.hfX();
        this.CSD = this.CSA.hfW();
        this.aTD--;
    }

    @Override // org.xml.sax.ext.LexicalHandler
    public final void endEntity(String str) throws SAXException {
        if (this.CSE.aSF || true != this.CSE.gq(this.aTD + 1)) {
            this.aTv--;
            this.aTh = null;
            if (this.aTv == 0) {
                this.aTw = true;
            }
        }
    }

    @Override // org.xml.sax.helpers.DefaultHandler, org.xml.sax.ContentHandler
    public final void endPrefixMapping(String str) throws SAXException {
        this.CSB.ajs(str);
        this.aTp = this.CSB.aUU.size();
    }

    @Override // org.xml.sax.helpers.DefaultHandler, org.xml.sax.ErrorHandler
    public final void error(SAXParseException sAXParseException) throws SAXException {
        throw sAXParseException;
    }

    @Override // org.xml.sax.ext.DeclHandler
    public final void externalEntityDecl(String str, String str2, String str3) throws SAXException {
        abjf abjf = new abjf(str, str2, str3);
        if (this.aTw) {
            if (this.aTt) {
                cT(abjf);
            }
        } else if (this.aTu) {
            cU(abjf);
        }
    }

    @Override // org.xml.sax.helpers.DefaultHandler, org.xml.sax.ErrorHandler
    public final void fatalError(SAXParseException sAXParseException) throws SAXException {
        throw sAXParseException;
    }

    public final abio hfV() {
        if (this.CSz == null) {
            String encoding = getEncoding();
            DocumentFactory documentFactory = this.CSi;
            abki abki = new abki();
            abki.CSi = documentFactory;
            abki.cr(encoding);
            abki.setEntityResolver(this.aTq);
            if (this.aTr != null) {
                abki.setName(this.aTr.getSystemId());
            }
            this.CSz = abki;
        }
        return this.CSz;
    }

    @Override // org.xml.sax.ext.DeclHandler
    public final void internalEntityDecl(String str, String str2) throws SAXException {
        if (this.aTw) {
            if (this.aTt) {
                cT(new abjh(str, str2));
            }
        } else if (this.aTu) {
            cU(new abjh(str, str2));
        }
    }

    @Override // org.xml.sax.helpers.DefaultHandler, org.xml.sax.DTDHandler
    public final void notationDecl(String str, String str2, String str3) throws SAXException {
    }

    @Override // org.xml.sax.helpers.DefaultHandler, org.xml.sax.ContentHandler
    public final void processingInstruction(String str, String str2) throws SAXException {
        if (this.aTx && this.aTy) {
            Ix();
        }
        if (this.CSD != null) {
            this.CSD.iV(str, str2);
        } else {
            hfV().iR(str, str2);
        }
    }

    public final void setDocumentLocator(Locator locator) {
        this.aTg = locator;
    }

    @Override // org.xml.sax.ext.LexicalHandler
    public final void startCDATA() throws SAXException {
        this.aTj = true;
        this.aTk = new StringBuffer();
    }

    @Override // org.xml.sax.ext.LexicalHandler
    public final void startDTD(String str, String str2, String str3) throws SAXException {
        hfV().bx(str, str2, str3);
        this.aTi = true;
        this.aTw = true;
    }

    @Override // org.xml.sax.helpers.DefaultHandler, org.xml.sax.ContentHandler
    public final void startDocument() throws SAXException {
        this.CSz = null;
        this.CSD = null;
        this.CSA.clear();
        if (this.CSC != null && (this.CSC instanceof abjj)) {
            this.CSA.CSm = (abjj) this.CSC;
        }
        this.CSB.clear();
        this.aTp = 0;
        if (this.aTx && this.aTA == null) {
            this.aTA = new StringBuffer();
        }
        this.aTy = false;
    }

    @Override // org.xml.sax.helpers.DefaultHandler, org.xml.sax.ContentHandler
    public final void startElement(String str, String str2, String str3, Attributes attributes) throws SAXException {
        boolean gq;
        String str4;
        if (this.aTx && this.aTy) {
            Ix();
        }
        this.aTD++;
        if (!this.CSE.aSF) {
            abjm abjm = this.CSE;
            abkw abkw = this.CSB;
            int i = this.aTD;
            if (true == abjm.gq(i)) {
                gq = true;
            } else {
                String value = attributes.getValue("http://schemas.openxmlformats.org/markup-compatibility/2006", "Ignorable");
                if (value != null) {
                    for (String str5 : value.split(MinimalPrettyPrinter.DEFAULT_ROOT_VALUE_SEPARATOR)) {
                        abiw ajr = abkw.ajr(str5);
                        String str6 = ajr != null ? ajr.uri : null;
                        if (str6 != null && abjm.CSn.w(str6, null, true) == null) {
                            abjm.bX(str6, i);
                        }
                    }
                }
                String value2 = attributes.getValue("http://schemas.openxmlformats.org/markup-compatibility/2006", "ProcessContent");
                if (value2 != null) {
                    for (String str7 : value2.split(MinimalPrettyPrinter.DEFAULT_ROOT_VALUE_SEPARATOR)) {
                        String[] split = str7.split(Message.SEPARATE2);
                        if (split.length >= 2) {
                            String str8 = split[0];
                            String str9 = split[1];
                            abiw ajr2 = abkw.ajr(str8);
                            String str10 = ajr2 != null ? ajr2.uri : null;
                            if (str10 != null && abjm.CSn.w(str10, null, true) == null) {
                                abjm.CSp.p(str10, str9, i);
                            }
                        }
                    }
                }
                String value3 = attributes.getValue("http://schemas.openxmlformats.org/markup-compatibility/2006", "MustUnderstand");
                if (value3 != null) {
                    for (String str11 : value3.split(MinimalPrettyPrinter.DEFAULT_ROOT_VALUE_SEPARATOR)) {
                        abiw ajr3 = abkw.ajr(str11);
                        String str12 = ajr3 != null ? ajr3.uri : null;
                        if (str12 != null && abjm.CSn.w(str12, null, true) == null) {
                            ev.eJ();
                            abjm.bX(str12, i);
                        }
                    }
                }
                if ("http://schemas.openxmlformats.org/markup-compatibility/2006".equals(str)) {
                    if ("AlternateContent".equals(str2)) {
                        abjm.CSq.cq(i, i + 1, abjm.e.CSw);
                    } else if ("Choice".equals(str2)) {
                        int length = attributes.getLength();
                        int i2 = 0;
                        while (true) {
                            if (i2 >= length) {
                                str4 = null;
                                break;
                            } else if ("Requires".equals(attributes.getLocalName(i2))) {
                                str4 = attributes.getValue(i2);
                                break;
                            } else {
                                i2++;
                            }
                        }
                        if (str4 != null) {
                            abiw ajr4 = abkw.ajr(str4);
                            String str13 = ajr4 != null ? ajr4.uri : null;
                            abjm.c peek = abjm.CSq.aSK.size() <= 0 ? null : abjm.CSq.aSK.peek();
                            if (abjm.CSn.w(str13, null, true) == null || abjm.e.CSx == peek.CSu) {
                                abjm.CSq.cq(i, MoPubNativeAdPositioning.MoPubClientPositioning.NO_REPEAT, abjm.e.CSv);
                            } else {
                                peek.CSu = abjm.e.CSx;
                                abjm.CSq.cq(i, i + 1, abjm.e.CSv);
                            }
                        }
                    } else if ("Fallback".equals(str2)) {
                        if (abjm.e.CSx != (abjm.CSq.aSK.size() <= 0 ? null : abjm.CSq.aSK.peek()).CSu) {
                            abjm.CSq.cq(i, i + 1, abjm.e.CSv);
                        } else {
                            abjm.CSq.cq(i, MoPubNativeAdPositioning.MoPubClientPositioning.NO_REPEAT, abjm.e.CSv);
                        }
                    }
                } else if (abjm.CSo.w(str, null, true) != null) {
                    if (abjm.CSp.w(str, str2, false) != null) {
                        abjm.CSq.cq(i, i + 1, abjm.e.CSv);
                    } else {
                        abjm.CSq.cq(i, MoPubNativeAdPositioning.MoPubClientPositioning.NO_REPEAT, abjm.e.CSv);
                    }
                }
                gq = abjm.gq(i);
            }
            if (true == gq) {
                this.aTp = this.CSB.aUU.size();
                return;
            }
        }
        abjb bz = this.CSB.bz(str, str2, str3);
        abik abik = this.CSD;
        if (abik == null) {
            abik = hfV();
        }
        abir a = abik.a(bz);
        int size = this.CSB.aUU.size();
        while (this.aTp < size) {
            a.a(this.CSB.aUU.get(this.aTp));
            this.aTp++;
        }
        ev.eH();
        int length2 = attributes.getLength();
        if (length2 > 0) {
            a.a(attributes, length2, this.CSB, false, this.CSE);
        }
        this.CSA.c(a);
        this.CSD = a;
        this.aTh = null;
        if (this.CSC != null) {
            this.CSC.a(this.CSA);
        }
    }

    @Override // org.xml.sax.ext.LexicalHandler
    public final void startEntity(String str) throws SAXException {
        boolean z = true;
        if (this.CSE.aSF || true != this.CSE.gq(this.aTD + 1)) {
            this.aTv++;
            this.aTh = null;
            if (!this.aTi) {
                if (!"amp".equals(str) && !"apos".equals(str) && !"gt".equals(str) && !"lt".equals(str) && !"quot".equals(str)) {
                    z = false;
                }
                if (!z) {
                    this.aTh = str;
                }
            }
            this.aTw = false;
        }
    }

    @Override // org.xml.sax.helpers.DefaultHandler, org.xml.sax.ContentHandler
    public final void startPrefixMapping(String str, String str2) throws SAXException {
        this.CSB.t(str, str2);
    }

    @Override // org.xml.sax.helpers.DefaultHandler, org.xml.sax.DTDHandler
    public final void unparsedEntityDecl(String str, String str2, String str3, String str4) throws SAXException {
    }

    @Override // org.xml.sax.helpers.DefaultHandler, org.xml.sax.ErrorHandler
    public final void warning(SAXParseException sAXParseException) throws SAXException {
    }
}